package nl.justobjects.pushlet.test;

import common.RssParser;

import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.EventPullSource;

public class CometDemoPull {
    
    static public class CometRatePull extends EventPullSource{
    	static int i=1;
        @Override
        protected long getSleepTime() {
            return 10000L; //这里是设置了一个轮回的时间间隔
        }

        @Override
        protected Event pullEvent() {
            Event event = Event.createDataEvent("/CometDemo/TestRate"); //这里创建一个服务。
            //以下是发送到客户端的数据
            if(Math.random()>0.1){
            	RssParser.parse();            	
            	String news=RssParser.getNews();
            	//System.err.println(news);
            	event.setField("message",news);
            	i++;
            	if(i>100)
            		i=1;
            }
            return event;
        }
        
    }
}